package com.atguigu.url.config;

import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @version V1.0
 * @author: zgc
 * @date: 2020/9/17 9:46
 * @description:
 */
@Configuration
public class HttpClientPoolConfig {


    @Bean
    public PoolingHttpClientConnectionManager poolingHttpClientConnectionManager() {

        PoolingHttpClientConnectionManager pcm = new PoolingHttpClientConnectionManager();

        //爬虫服务器最大连接数
        pcm.setMaxTotal(100);
        //每个Host网站主机分配的最大连接数
        pcm.setDefaultMaxPerRoute(10);

        return pcm;
    }

}

